//
//  PintuView.m
//  PingTu
//
//  Created by Yangfan on 15/2/5.
//  Copyright (c) 2015年 4gread. All rights reserved.
//

#import "PintuView.h"
#import <MBProgressHUD/MBProgressHUD.h>

@implementation PintuView

- (id)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self DataLoad];
    }
    return self;
}

- (void)DataLoad {
    _isSaved = false;
}

- (void)UI {
    CGRect rect;
    if (ISIPHONE4) {
        rect = CGRectMake(0, viewHeight - 94, viewWidth, 94);
    } else {
        rect = CGRectMake(0, viewHeight - 94, viewWidth, 94);
    }
    // 下面放置的用于滚动选择的模板
    _bottomTypeView = [[BottomTypeView alloc] initWithFrame:rect];
    _bottomTypeView.delegate = self;
    [_bottomTypeView setPicNumber:[self returnIntFromNSUInteger:_assets.count]];
    [_bottomTypeView firstInto];
    [self addSubview:_bottomTypeView];
}

- (void)setAssetsIntoPintuView:(NSArray *)assets {
    _assets = assets;
    [self UI];
}

#pragma mark - BottomTypeViewDelegate
-(void)selectWhichTypeMuBan:(int)whichMuBan {

    if (_mainContentView == nil) {
        _mainContentView = [[MainContentView alloc] initWithFrame:self.bounds];
        [_mainContentView setAssetsIntoPintuView:_assets];
        [self addSubview:_mainContentView];
    } else {
        [_mainContentView updateUI:whichMuBan];
    }
}

@end